﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        HttpCookieCollection checkCode = Request.Cookies;
        string a = TextBox7.Text;
        string b = checkCode["CheckCode"].Value;
        if (TextBox5.Text == "" || TextBox7.Text == "")
        //if (TextBox5.Text == "" )
        {
            Response.Write("<script>alert('请输入完整！')</script>");
            Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

        }
        //else if (!a.Equals(b, StringComparison.OrdinalIgnoreCase))
        //{
        //    Response.Write("<script>alert('验证码有误！')</script>");
        //    Response.Write("<script language=javascript>window.location.href='Index.aspx'</script>");

        //}
        else
        {
            using (DataClassesDataContext ds = new DataClassesDataContext())
            {
                var b1 = (from q in ds.admin
                          where q.yonghuming == TextBox5.Text.Trim()
                          where q.PWD == TextBox6.Text.Trim()
                          select q).Any();
                if (b1 == true)
                {
                    Session["ID"] = TextBox5.Text;
                    Response.Redirect("manage/admin.aspx");
                }
                else
                {
                    Response.Write("<script language=javascript>alert('用户名或密码错误！')</script>");


                }
            }

        }


    }
}